<!DOCTYPE html>
<html>
<head>
	<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link rel="stylesheet" href="css/map.css">
    <link rel="stylesheet" href="css/weui.css">
    <!--<link rel="stylesheet" href="css/jquery-weui.min.css">-->
    <link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
    <script type="text/javascript" src="http://webapi.amap.com/maps?v=1.4.1&key=您申请的key值"></script>
    <script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script>
    	
    <title>天津智能公共自行车</title>
    <style type="text/css">
    	#container{
    		margin-top: 50px;
    	}
    	#tip{
    		margin-top: 50px;
    	}
    </style>
</head>
<body>
<div class="weui-cells main_head">
    <div class="weui-cell">
        <div class="weui-cell__hd"><a href="login.html"><img class="head_user" src="img/temp.png" alt=""></a></div>
        <div class="weui-cell__bd">
            <p class="main_head_center">天津智能公共自行车</p>
        </div>
        <div class="weui-cell__ft"><a href="unlock.html"><img class="head_search" src="img/search.png" alt=""></a></div>
    </div>
</div>
<div class="bigdiv">
    <div id='container'></div>
<div id="tip"></div>
</div>
<script src="js/jquery-2.1.4.js"></script>
<script src="js/fastclick.js"></script>
<script src="js/init.js"></script>
<script>
    $(function () {
        FastClick.attach(document.body);
    });
</script>
<script src="js/jquery-weui.min.js"></script>

<script type="text/javascript" src="js/baidu_map_api.js"></script>
<script type="text/javascript" src="js/map.js"></script>
<script type="text/javascript">
/***************************************
接入高德地图API开始
***************************************/
    var map, geolocation;
    //加载地图，调用浏览器定位服务
    map = new AMap.Map('container', {
        resizeEnable: true
    });
    map.plugin('AMap.Geolocation', function() {
        geolocation = new AMap.Geolocation({
            enableHighAccuracy: true,//是否使用高精度定位，默认:true
            timeout: 10000,          //超过10秒后停止定位，默认：无穷大
            buttonOffset: new AMap.Pixel(10, 20),//定位按钮与设置的停靠位置的偏移量，默认：Pixel(10, 20)
            zoomToAccuracy: true,      //定位成功后调整地图视野范围使定位位置及精度范围视野内可见，默认：false
            buttonPosition:'RB'
        });
        map.addControl(geolocation);
        console.log(geolocation)
        geolocation.getCurrentPosition();
        AMap.event.addListener(geolocation, 'complete', onComplete);//返回定位信息
        AMap.event.addListener(geolocation, 'error', onError);      //返回定位出错信息
    });
    //解析定位结果
    function onComplete(data) {
        var str=['定位成功'];
        console.log(data.position.getLng())
        str.push('经度：' + data.position.getLng());
        str.push('纬度：' + data.position.getLat());
        if(data.accuracy){
             str.push('精度：' + data.accuracy + ' 米');
        }//如为IP精确定位结果则没有精度信息
        str.push('是否经过偏移：' + (data.isConverted ? '是' : '否'));
        document.getElementById('tip').innerHTML = str.join('<br>');
    }
    //解析定位错误信息
    function onError(data) {
        document.getElementById('tip').innerHTML = '定位失败';
    }
    //接入高德地图结束
</script>
</body>
</html>
